package com.scedu.dto;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.scedu.domain.OrderDetail;
import com.scedu.enums.OrderStatusEnums;
import com.scedu.enums.PayStatusEnums;
import com.scedu.utils.EnumUtil;
import com.scedu.utils.serializer.Date2LongSerializer;
import lombok.Data;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/*
数据传输对象 DTO

 */
@Data
//@JsonInclude(JsonInclude.Include.NON_NULL)
public class OrderDTO {
    private String orderId;
    private  String orderName;
    private  String orderPhone;
    private  String orderAddress;
    private String orderOpenid;
    private BigDecimal orderAmount;
    private Integer orderStatus; //订单状态,默认0 新订单
    private Integer payStatus; //支付状态,默认0，未支付
    @JsonSerialize(using = Date2LongSerializer.class) //DATE转为时间戳
    private Date create_time;
    @JsonSerialize(using = Date2LongSerializer.class) //DATE转为时间戳
    private  Date  update_time;
    List<OrderDetail> orderDetailList =new ArrayList<>();
    @JsonIgnore //会多出getOrderStatusEnums属性
    public OrderStatusEnums getOrderStatusEnums(){
       return EnumUtil.getByCode(orderStatus,OrderStatusEnums.class);

    }
    @JsonIgnore
    public PayStatusEnums getPayStatusEnums(){
       return EnumUtil.getByCode(payStatus,PayStatusEnums.class);
    }
}
